define(function (require, exports, module) {
    var angular = require('angular');
    require("angular-ui");

    angular.module('app', [])
        .constant('api.path', "/api/index.php?r=xmf/xmf-user/")
        .factory('ExpandTeamService', [
            '$http',
            'api.path',
            function ($http, api_path) {
                var httpClient = {
                    get: function (api, data) {
                        var url = api_path + api;
                        var search = (data && data.search) || {};
                        angular.forEach(search, function (val, key) {
                            url += "&" + key + "=" + val;
                        });

                        return $http.get(url)
                            .then(function (res) {
                                if (res.retCode === "0") {
                                    return res;
                                }
                            })
                    },
                    post: function (api, data) {
                        return $http.post(api_path + api, (data && data.data) || {})
                            .then(function (res) {
                                if (res.retCode === "0") {
                                    return res;
                                }
                            })
                    }
                }
                return {
                    getActivityList: function (search) {
                        return httpClient.get('list', search)
                    },
                    createActivity:function(data){
                        return httpClient.post('list', data)
                    },
                    updateActivity:function(data){
                        return httpClient.post('list', data)
                    },
                    deleteActivity: function(data){
                        return httpClient.post('list', data)
                    }
                }
            }
        ])
        .controller('MainController', [
            '$scope',
            '$rootScope',
            'ExpandTeamService',
            function ($scope, $rootScope, service) {
                
            }
        ])

    angular.bootstrap(document, ['app']);
});
